/**
 * 这个类演示了文档注释
 *
 * @author zhengzheng
 * @version 1.0
 */
public class SquareNum {
    public static void main(String[] args) {
        SquareNum ob = new SquareNum();
        double val = 0;
        System.out.println("Enter value to be squared: ");
        try {
            val = ob.getNumber();
        } catch (java.io.IOException e) {
            e.printStackTrace();
        } catch (NumberFormatException e) {
            System.out.println("当前输入不合法，已默认替换成0");
        }
        val = ob.square(val);
        System.out.println("Squared value is " + val);
    }

    /**
     * This method inputs a number from the user.
     *
     * @return The value input as a double.
     * @throws java.io.IOException   IOException On input error.
     * @throws NumberFormatException if the string does not contain a parsable double.
     * @see java.io.IOException
     * @see NumberFormatException
     */
    public double getNumber() throws java.io.IOException, NumberFormatException {
        java.io.InputStreamReader isr = new java.io.InputStreamReader(System.in);
        java.io.BufferedReader inData = new java.io.BufferedReader(isr);
        String str = "";
        str = inData.readLine();
        return (new Double(str)).doubleValue();
//        return 0;
    }

    /**
     * This method returns the square of num.
     * This is a multiline description. You can use as
     * many lines as you like.
     *
     * @param num The value to be squared.
     * @return num squared.
     */
    public double square(double num) {
        return num * num;
    }
}
//
//javac -encoding utf-8 -cp mail.jar  MailSender.java
//java -Dfile.encoding=utf-8 -cp "mail.jar:" MailSender
//-encoding utf8 -docencoding utf8 -charset utf8